home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / sys / runtime / base.h next >
C/C++ Source or Header  |  2000-04-03  |  4KB  |  157 lines

  1. /*
  2. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  3. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  4. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  5. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  6. -- this header is kept unaltered, and a notification of the changes is added.
  7. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  8. -- another product.
  9. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  10. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  11. --                       http://SmallEiffel.loria.fr
  12. --
  13. */
  14. /*
  15.   This file (SmallEiffel/sys/runtime/base.h) contains all basic Eiffel
  16.   type definitions.
  17.   This file is automatically included in the header for all modes of 
  18.   compilation : -boost, -no_check, -require_check, -ensure_check, ...
  19.   This file is also included in the header of any cecil file (when the
  20.   -cecil option is used).
  21.   This file is also included in the header file of C++ wrappers (when
  22.   using the external "C++" clause).
  23. */
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <math.h>
  27. #include <stdlib.h>
  28. #include <signal.h>
  29. #include <stddef.h>
  30. #include <stdarg.h>
  31. #include <limits.h>
  32. #include <float.h>
  33. #include <setjmp.h>
  34.  
  35. #if 0
  36. #include <sys/types.h>
  37. #include <sys/stat.h>
  38. #include <fcntl.h>
  39. #ifdef WIN32
  40. #include <windows.h>
  41. #else
  42. #ifndef O_RDONLY
  43. #include <sys/file.h>
  44. #endif
  45. #ifndef O_RDONLY
  46. #define O_RDONLY 0000
  47. #endif
  48. #endif
  49. #endif
  50.  
  51. /* 
  52.     On Linux glibc systems, we need to use sig.* versions of jmp_buf,
  53.     setjmp and longjmp to preserve the signal handling context.
  54.     Currently, the way I figured to detect this is if _SIGSET_H_types has
  55.     been defined in /usr/include/setjmp.h.
  56. */
  57. #ifdef _SIGSET_H_types
  58. #define JMP_BUF    sigjmp_buf
  59. #define SETJMP(x)  sigsetjmp( (x), 1)
  60. #define LONGJMP    siglongjmp
  61. #else
  62. #define JMP_BUF    jmp_buf
  63. #define SETJMP(x)  setjmp( (x) )
  64. #define LONGJMP    longjmp
  65. #endif
  66.  
  67. /* 
  68.     Type to store reference objects Id :
  69.  */
  70. typedef int Tid;
  71.  
  72. typedef struct S0 T0;
  73.  
  74. struct S0{
  75.   Tid id;
  76. };
  77.  
  78. /* 
  79.     The default channel used to print runtime error messages :
  80. */
  81. #define SE_ERR stderr
  82.  
  83. /* 
  84.     Eiffel type INTEGER is #2 :
  85. */
  86. typedef int T2;
  87. #define EIF_INTEGER T2
  88. #define M2 (0)
  89. #define EIF_INTEGER_BITS (CHAR_BIT*sizeof(int))
  90. #define EIF_MINIMUM_INTEGER (INT_MIN)
  91. #define EIF_MAXIMUM_INTEGER (INT_MAX)
  92.  
  93. /*
  94.   Eiffel type CHARACTER is #3 :
  95. */
  96. typedef unsigned char T3;
  97. #define EIF_CHARACTER T3
  98. #define M3 (0)
  99. #define EIF_CHARACTER_BITS (CHAR_BIT)
  100. #define EIF_MINIMUM_CHARACTER_CODE (0)
  101. #define EIF_MAXIMUM_CHARACTER_CODE (255)
  102. #define T3code(x) ((T2)(x))
  103. #define T3to_integer(x) ((T2)((char)(x)))
  104. #define T3to_bit(x) (x)
  105.  
  106. /*
  107.   Eiffel type REAL is #4 :
  108. */
  109. typedef float T4;
  110. #define EIF_REAL T4
  111. #define M4 (0.0)
  112. #define EIF_REAL_BITS (CHAR_BIT*sizeof(float))
  113. #define EIF_MINIMUM_REAL (-(FLT_MAX))
  114. #define EIF_MAXIMUM_REAL (FLT_MAX)
  115. #define T2toT4(x) ((T4)(x))
  116.  
  117. /*
  118.   Eiffel type DOUBLE is #5 :
  119. */
  120. typedef double T5;
  121. #define EIF_DOUBLE T5
  122. #define M5 (0.0)
  123. #define EIF_DOUBLE_BITS (CHAR_BIT*sizeof(double))
  124. #define EIF_MINIMUM_DOUBLE (-(DBL_MAX))
  125. #define EIF_MAXIMUM_DOUBLE (DBL_MAX)
  126. #define T2toT5(x) ((T5)(x))
  127. #define T4toT5(x) ((T5)(x))
  128.  
  129. /*
  130.   Eiffel type BOOLEAN is #6 :
  131. */
  132. typedef char T6;
  133. #define EIF_BOOLEAN T6
  134. #define M6 (0)
  135. #define EIF_BOOLEAN_BITS (CHAR_BIT)
  136.  
  137. /* 
  138.     Eiffel type POINTER is #8 :
  139. */
  140. typedef void* T8;
  141. #define EIF_POINTER T8
  142. #define M8 (NULL)
  143. #define EIF_POINTER_BITS (CHAR_BIT*sizeof(void*))
  144.  
  145. /*
  146.   To use type STRING on the C side :
  147. */
  148. #define EIF_STRING T7*
  149.  
  150. /*
  151.   Some Other EIF_* defined in ETL :
  152. */
  153. #define eif_access(x) ((char*)(x))
  154. #define EIF_REFERENCE T0*
  155. #define EIF_OBJ T0*
  156. #define EIF_OBJECT EIF_OBJ
  157.